package thread;

public class demo3 {
    private static int count ;

    public static void main(String[] args) throws InterruptedException {
        Object clock1 = new Object();
        Thread t1 = new Thread(()->{
            for(int i = 0;i<50000;i++){
                synchronized (clock1){
                    count++;
                }
            }
        }) ;

        Thread t2 = new Thread(()->{
            for(int i = 0;i<50000;i++){
                //锁的可重入性
                synchronized (clock1){
                    synchronized (clock1){
                        count++;
                    }
                }
            }
        }) ;

        t1.start();
        t2.start();

        t1.join();
        t2.join();
        System.out.println(count);
    }
}
